<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class AddUserServiceRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'user_id' => 'required|integer|exists:users,id',
            'service_id' => 'required|integer|exists:services,id',
            'start_time' => 'required|Date',
            'end_time' => 'required|Date'
        ];
    }

    public function messages()
    {
        return [
            'user_id.required' => '用户ID不能为空',
            'user_id.integer' => '必须是整数',
            'user_id.exists' => '用户不存在',
            'service_id.required' => '服务ID不能为空',
            'service_id.integer' => '必须是整数',
            'service_id.exists' => '服务不存在',
            'start_time.required' => '开始时间必须存在',
            'start_time.Date' => '必须是时间格式',
            'end_time.required' => '结束时间必须存在',
            'end_time.Date' => '必须是时间格式'
        ];
    }
}
